

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.ico">
  <link rel="icon" href="/img/favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="Try not to become a man of success but rather try to become a man of value. ">
  <meta name="author" content="kinzun">
  <meta name="keywords" content>
  <meta name="description" content="一.模块的简单认识​    什么是模块。模块就是我们把特定功能的代码进行归类的结果。: ⼀一条代码 &amp;lt; 语句句块 &amp;lt; 代码块(函数, 类) &amp;lt; 模块 我们写py文件也是模块。切记，自己的写的模块，不要和python冲突。 引入模块的方式：  import 模块 from xxx import 模块  二.collections 模块Collections 模块主要封装一些关于集合">
<meta name="keywords" content="Python">
<meta property="og:type" content="article">
<meta property="og:title" content="Python常用模块01">
<meta property="og:url" content="https://kinzun.github.io/2018/10/07/python常用模块01/index.html">
<meta property="og:site_name" content="kinzun">
<meta property="og:description" content="一.模块的简单认识​    什么是模块。模块就是我们把特定功能的代码进行归类的结果。: ⼀一条代码 &amp;lt; 语句句块 &amp;lt; 代码块(函数, 类) &amp;lt; 模块 我们写py文件也是模块。切记，自己的写的模块，不要和python冲突。 引入模块的方式：  import 模块 from xxx import 模块  二.collections 模块Collections 模块主要封装一些关于集合">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-10-28T07:00:29.683Z">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Python常用模块01">
<meta name="twitter:description" content="一.模块的简单认识​    什么是模块。模块就是我们把特定功能的代码进行归类的结果。: ⼀一条代码 &amp;lt; 语句句块 &amp;lt; 代码块(函数, 类) &amp;lt; 模块 我们写py文件也是模块。切记，自己的写的模块，不要和python冲突。 引入模块的方式：  import 模块 from xxx import 模块  二.collections 模块Collections 模块主要封装一些关于集合">
  
  <title>Python常用模块01 - kinzun</title>

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css">


  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css">
  <link rel="stylesheet" href="/lib/hint/hint.min.css">

  
    
    
      
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css">
    
  

  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css">
  


<!-- 主题依赖的图标库，不要自行修改 -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">

<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">

<link rel="stylesheet" href="/css/main.css">

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"kinzun.github.io","root":"/","version":"1.8.12","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname"}},"search_path":"/local-search.xml"};
  </script>
  <script src="/js/utils.js"></script>
  <script src="/js/color-schema.js"></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>kinzun</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="Python常用模块01">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2018-10-07 23:27" pubdate>
        2018年10月7日 晚上
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      7k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      22 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Python常用模块01</h1>
            
            <div class="markdown-body">
              <h4 id="一-模块的简单认识"><a href="#一-模块的简单认识" class="headerlink" title="一.模块的简单认识"></a>一.模块的简单认识</h4><p>​    什么是模块。模块就是我们把特定功能的代码进行归类的结果。: ⼀一条代码 &lt; 语句句块 &lt; 代码块(函数, 类) &lt; 模块 我们写py文件也是模块。切记，自己的写的模块，不要和python冲突。</p>
<p>引入模块的方式：</p>
<ul>
<li><code>import</code> 模块</li>
<li><code>from xxx import</code> 模块</li>
</ul>
<h4 id="二-collections-模块"><a href="#二-collections-模块" class="headerlink" title="二.collections 模块"></a>二.collections 模块</h4><p>Collections 模块主要封装一些关于集合的相关操作。比如 Iterable, Iterator.</p>
<blockquote>
<p>Iterable: 可迭代对象. 内部包含<strong>iter</strong>()函数<br>Iterator: 迭代器. 内部包含<strong>iter</strong>() 同时包含<strong>next</strong>().</p>
</blockquote>
<ol>
<li><p>Counter 是一个计数器。</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><span class="hljs-comment">#统计下字符出现的次数</span><br>low：<br>s = <span class="hljs-string">'sadfsdfsdfdsfsdfghgjghxczvcvcvnjsqero'</span><br>dic = &#123;&#125;<br><span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> s:<br>    dic[i] = dic.get(i,<span class="hljs-number">0</span>)  +<span class="hljs-number">1</span> <span class="hljs-comment">#dic.get(i,0) 如果值不存在就返回0  </span><br><br>print(dic)    <br><span class="hljs-comment">#模块中</span><br><br>nb：<br>s = <span class="hljs-string">'sadfsdfsdfdsfsdfghgjghxczvcvcvnjsqero'</span><br><br><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> Counter<br>c = Counter(s) <span class="hljs-comment">#创建一个Counter 对象</span><br><br><br>print(c)<br>print(c[<span class="hljs-string">"s"</span>]) <span class="hljs-comment"># 用起来和字典差不多</span><br></code></pre></div></td></tr></table></figure>
</li>
<li><p><code>deque</code> 双向队列.</p>
</li>
</ol>
<p>   说双向队列之前我们需要了解两种数据结构. 1. 栈, 2.  队列</p>
<ul>
<li><p>队列: 先进先出 First In Fisrt out #谁先进去，谁先处理。如买票，抢红包</p>
</li>
<li><p>栈：先进后出 First In Last out #堆？ 砌墙的砖头，拆的话会是后面的先出</p>
</li>
</ul>
   <figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><span class="hljs-comment">##只做学习样本，无实际意义</span><br><br><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">StackFullError</span><span class="hljs-params">(Exception)</span>:</span><br>    <span class="hljs-keyword">pass</span><br><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">StackEmptyError</span><span class="hljs-params">(Exception)</span>:</span><br>    <span class="hljs-keyword">pass</span><br><br><br><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Stack</span>:</span><br><br>    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self,size)</span>:</span><br>        self.index = <span class="hljs-number">0</span> <span class="hljs-comment">#栈顶指针</span><br>        self.size = size<br>        self.lst = [] <span class="hljs-comment"># 容器</span><br><br>    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">push</span><span class="hljs-params">(self,el)</span>:</span> <span class="hljs-comment">#放</span><br>        <span class="hljs-keyword">if</span> self.index &lt; self.size: <span class="hljs-comment">#为装满</span><br>            self.lst.insert(self.index,el)<br>            self.index  += <span class="hljs-number">1</span><br>        <span class="hljs-keyword">else</span>: <span class="hljs-comment">#装满了</span><br>            <span class="hljs-keyword">raise</span> StackFullError(<span class="hljs-string">"the stack is full!"</span>)<br>    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">pop</span><span class="hljs-params">(self)</span>:</span> <span class="hljs-comment"># 取</span><br>        <span class="hljs-keyword">if</span> self.index &gt; <span class="hljs-number">0</span> :<br>            self.index -= <span class="hljs-number">1</span><br>            <span class="hljs-keyword">return</span> self.lst[self.index]<br>        <span class="hljs-keyword">else</span>: <span class="hljs-comment">#空了</span><br>            <span class="hljs-keyword">raise</span> StackEmptyError(<span class="hljs-string">"the stack is empty!"</span>)<br><br><br><span class="hljs-comment">#使用</span><br><span class="hljs-comment">#实例化</span><br>s = Stack(<span class="hljs-number">5</span>)<br><br>s.push(<span class="hljs-string">"馒头1"</span>)<br>print(s.pop())<br>s.push(<span class="hljs-string">"馒头3"</span>)<br>s.push(<span class="hljs-string">"馒头4"</span>)<br>s.push(<span class="hljs-string">"馒头5"</span>)<br>print(s.index)<br>print(s.pop())<br>print(s.index)<br></code></pre></div></td></tr></table></figure>
<p>   队列：python提供<code>queue</code></p>
   <figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">improt queue<br><br>q = queue.Queue() <span class="hljs-comment"># 创建队列</span><br>q.put(<span class="hljs-string">'go'</span>) <span class="hljs-comment">#放入元素</span><br>q.put(<span class="hljs-string">'a'</span>)<br>q.put(<span class="hljs-string">'b'</span>)<br><br>print(q.get()) <span class="hljs-comment">#</span><br>print(q.get())<br>print(q.get())<br>print(q.get())  <span class="hljs-comment"># 在等下一个元素。 阻塞</span><br></code></pre></div></td></tr></table></figure>
<p>   <code>deque</code></p>
   <figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><br><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> deque<br><br>d = deque() <span class="hljs-comment"># 创建双向队列</span><br><br><br>d.append(<span class="hljs-string">"普罗米修斯"</span>) <span class="hljs-comment"># 默认右侧添加</span><br>d.append(<span class="hljs-string">"影"</span>)<br>d.append(<span class="hljs-string">"星际穿越"</span>)<br>d.append(<span class="hljs-string">"契约"</span>)<br>print(d)<br>d.appendleft(<span class="hljs-string">'赌徒默示录'</span>) <span class="hljs-comment"># 左侧添加</span><br>print(d)<br>d.pop() <span class="hljs-comment"># 从右边删除</span><br>print(d)<br></code></pre></div></td></tr></table></figure>
<ol start="3">
<li><p><code>Namedtuple</code> 命名元祖</p>
<p>给元祖内的元素进行命名。比如元祖有两个数，就以坐标形式对元素命名。使用<code>namedtuple</code> 对元素进行命名</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><br><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> namedtuple<br><br>po = namedtuple(<span class="hljs-string">'Point'</span>,[<span class="hljs-string">'x'</span>,<span class="hljs-string">'y'</span>]) <span class="hljs-comment">#定义了一个类</span><br>p = po(<span class="hljs-number">1</span>,<span class="hljs-number">2</span>) <span class="hljs-comment">#命名元祖</span><br>print(p)<br>print(p.x)<br>print(p.y)<br><br><span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">Point</span>:</span><br>    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self,x,y)</span>:</span><br>        self.x = x<br>        self.y = y<br></code></pre></div></td></tr></table></figure>
</li>
<li><p><code>orderdict</code>  和<code>defaultdict</code></p>
<p><code>orderdict</code>  顾名思义. 字典的key默认是无序的. 而<code>OrderedDict</code> 是有序的</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">python3<span class="hljs-number">.6</span> 以上使用的新算法，来自与pypy，节约<span class="hljs-number">20</span><span class="hljs-number">-30</span>%内存<br>d = &#123;<span class="hljs-string">'a'</span>:<span class="hljs-number">1</span>,<span class="hljs-string">'c'</span>:<span class="hljs-number">2</span>,<span class="hljs-string">'b'</span>:<span class="hljs-number">3</span>&#125;<br>print(d)<br><br><br><br><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> OrderedDict<br><br>od = OrderedDict(&#123;<span class="hljs-string">'a'</span>:<span class="hljs-number">1</span>,<span class="hljs-string">'c'</span>:<span class="hljs-number">2</span>,<span class="hljs-string">'b'</span>:<span class="hljs-number">3</span>&#125;)<br>print(od.get(<span class="hljs-string">'a'</span>))<br><br>print(od[<span class="hljs-string">'b'</span>])<br></code></pre></div></td></tr></table></figure>
<p><code>defaultdict</code> 可以给字典设置默认值。当key不存在时，直接获取默认值。</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><br><br><br><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> defaultdict<br>d = defaultdict(list) <span class="hljs-comment"># &#123;&#125;list() 必须callable</span><br>d[<span class="hljs-string">'张国荣'</span>] = <span class="hljs-string">'倩女幽魂'</span><br>print(d[<span class="hljs-string">'张国荣'</span>])<br>print(d[<span class="hljs-string">'宝宝'</span>]) <span class="hljs-comment"># 当key不存在的时候，返回默认值,其实就是callable()</span><br><br><br><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> defaultdict<br>lst  = [<span class="hljs-number">1123</span>,<span class="hljs-number">132</span>,<span class="hljs-number">33</span>,<span class="hljs-number">4</span>,<span class="hljs-number">4</span>,<span class="hljs-number">56</span>,<span class="hljs-number">123</span>,<span class="hljs-number">100</span>,<span class="hljs-number">13223</span>,<span class="hljs-number">44</span>,<span class="hljs-number">55</span>]<br><br>d = defaultdict(list)<br><br><span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> lst:<br>    <span class="hljs-keyword">if</span> el &gt; <span class="hljs-number">66</span>:<br>        d[<span class="hljs-string">'key1'</span>].append(el)<br>    <span class="hljs-keyword">else</span>:<br>        d[<span class="hljs-string">'key2'</span>].append(el)<br>print(d)<br><br><span class="hljs-comment">#以下代码时相同思路。</span><br><br>cars = [<span class="hljs-string">"鲁A 10086"</span>, <span class="hljs-string">"黑A 45678"</span>, <span class="hljs-string">"黑C 12345"</span>, <span class="hljs-string">"京B 00001"</span>, <span class="hljs-string">"京C 78912"</span>, <span class="hljs-string">"京A 66666"</span>]<br>locations = &#123;<span class="hljs-string">"鲁"</span>: <span class="hljs-string">"山东"</span>, <span class="hljs-string">"黑"</span>: <span class="hljs-string">"黑龙江"</span>, <span class="hljs-string">"京"</span>: <span class="hljs-string">"北京"</span>, <span class="hljs-string">"沪"</span>: <span class="hljs-string">"上海"</span>&#125;<br>dic = &#123;&#125;<br><br><span class="hljs-keyword">for</span> car <span class="hljs-keyword">in</span> cars: <span class="hljs-comment"># 每个车牌子 鲁A 10086</span><br>    paitou = car[<span class="hljs-number">0</span>] <span class="hljs-comment"># 鲁</span><br>    <span class="hljs-comment"># if dic.get(locations[paitou]) == None:</span><br>    <span class="hljs-comment">#     dic[locations[paitou]] = 1</span><br>    <span class="hljs-comment"># else:</span><br>    <span class="hljs-comment">#     dic[locations[paitou]] = dic[locations[paitou]]+1</span><br><br>    <span class="hljs-comment"># 省份 # "山东": 1, "黑龙江":1</span><br>    <span class="hljs-comment"># num = dic.get(locations[paitou], 0)</span><br>    <span class="hljs-comment"># num = num + 1</span><br>    <span class="hljs-comment"># dic[locations[paitou]] = num</span><br><br>    dic[locations[paitou]] = dic.setdefault(locations[paitou], <span class="hljs-number">0</span>) + <span class="hljs-number">1</span><br><br>print(dic)<br><br><br><br>lst  = [<span class="hljs-number">1123</span>,<span class="hljs-number">132</span>,<span class="hljs-number">33</span>,<span class="hljs-number">4</span>,<span class="hljs-number">4</span>,<span class="hljs-number">56</span>,<span class="hljs-number">123</span>,<span class="hljs-number">100</span>,<span class="hljs-number">13223</span>,<span class="hljs-number">44</span>,<span class="hljs-number">55</span>]<br>dic = &#123;&#125;<br><span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> lst:<br>    <span class="hljs-keyword">if</span> el &gt; <span class="hljs-number">66</span>:<br>        dic.setdefault(<span class="hljs-string">'key1'</span>,[]).append(el)<br><br>    <span class="hljs-keyword">else</span>:<br>        dic.setdefault(<span class="hljs-string">'key2'</span>,[]).append(el)<br>print(dic)<br></code></pre></div></td></tr></table></figure>
</li>
</ol>
<h4 id="三-时间模块"><a href="#三-时间模块" class="headerlink" title="三.时间模块"></a>三.时间模块</h4><p>​    时间模块，用与计算时间差，按客户要就展示时间…等</p>
<p>在python中时间分为三种表现形式：</p>
<ol>
<li><p><strong>时间戳（timestamp）</strong> 时间戳使用的是1970年01月01日 00点00分00秒到现在经历了多少秒用，float表示</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><span class="hljs-keyword">import</span> time<br>print(time.time()) <span class="hljs-comment"># 1538991585.099336 系统时间戳</span><br></code></pre></div></td></tr></table></figure>
</li>
<li><p><strong>格式化时间 (strfime)</strong> 可根据需要进行任意格式化</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">print(time.strftime(<span class="hljs-string">'%Y-%m-%d %H:%M:%S'</span>)) <span class="hljs-comment">#年月日，时分秒</span><br></code></pre></div></td></tr></table></figure>
<p>日期格式化标准</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">%y 两位数的年份表示（<span class="hljs-number">00</span><span class="hljs-number">-99</span>）<br>%Y 四位数的年份表示（<span class="hljs-number">000</span><span class="hljs-number">-9999</span>） <br>%m ⽉份（<span class="hljs-number">01</span><span class="hljs-number">-12</span>） <br>%d ⽉内中的⼀天（<span class="hljs-number">0</span><span class="hljs-number">-31</span>）<br>%H <span class="hljs-number">24</span>⼩时制⼩时数（<span class="hljs-number">0</span><span class="hljs-number">-23</span>）<br>%I <span class="hljs-number">12</span>⼩时制⼩时数（<span class="hljs-number">01</span><span class="hljs-number">-12</span>）<br>%M 分钟数（<span class="hljs-number">00</span>=<span class="hljs-number">59</span>）<br>%S 秒（<span class="hljs-number">00</span><span class="hljs-number">-59</span>） <br>%a 本地简化星期名称 <br>%A 本地完整星期名称<br>%b 本地简化的⽉份名称<br>%B 本地完整的⽉份名称 <br>%c 本地相应的⽇期表示和时间表示 <br>%j 年内的⼀天（<span class="hljs-number">001</span><span class="hljs-number">-366</span>） <br>%p 本地A.M.或P.M.的等价符 <br>%U ⼀年中的星期数（<span class="hljs-number">00</span><span class="hljs-number">-53</span>）星期天为星期的开始 <br>%w 星期（<span class="hljs-number">0</span><span class="hljs-number">-6</span>），星期天为星期的开始<br>%W ⼀年中的星期数（<span class="hljs-number">00</span><span class="hljs-number">-53</span>）星期⼀为星期的开始 <br>%x 本地相应的⽇期表示 %X 本地相应的时间表示<br>%Z 当前时区的名称 %<br>% %号本身<br><br>看⼀下结构化时间:<br></code></pre></div></td></tr></table></figure>
</li>
<li><p><strong>结构化时间（struct_time)</strong> </p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">print(time.localtime()) 结果:<br><br>time.struct_time(tm_year=<span class="hljs-number">2017</span>, tm_mon=<span class="hljs-number">05</span>, tm_mday=<span class="hljs-number">8</span>, tm_hour=<span class="hljs-number">10</span>, tm_min=<span class="hljs-number">24</span>, tm_sec=<span class="hljs-number">42</span>, tm_wday=<span class="hljs-number">0</span>, tm_yday=<span class="hljs-number">126</span>, tm_isdst=<span class="hljs-number">0</span>)<br></code></pre></div></td></tr></table></figure>
</li>
</ol>
<p><strong>转换时间</strong></p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><span class="hljs-comment">##时间戳 -&gt; 格式化时间</span><br><br><span class="hljs-comment">#1。把时间戳转化成结构化时间</span><br>f = <span class="hljs-number">188888888</span><br>st = time.localtime(f) <span class="hljs-comment">#结构化时间</span><br>print(st)<br><span class="hljs-comment">#2。结构化时间转 格式化时间</span><br>t = time.strftime(<span class="hljs-string">'%Y-%m-%d %H:%M:%S '</span>,st)<br>print(t)<br><br><span class="hljs-comment">#格式化转为时间戳</span><br>s = <span class="hljs-string">"1975-12-27 13:08:08 "</span> <br>t = time.strptime(s, <span class="hljs-string">"%Y-%m-%d %H:%M:%S"</span>) <span class="hljs-comment">#转为结构化</span><br>print(time.mktime(t)) <span class="hljs-comment"># 转换成时间戳</span><br></code></pre></div></td></tr></table></figure>
<h4 id="四-random模块"><a href="#四-random模块" class="headerlink" title="四. random模块"></a>四. random模块</h4><p>随机相关</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python"><span class="hljs-keyword">import</span> random<br><br>print(random.random()) <span class="hljs-comment"># 0-1⼩数 </span><br><br>print(random.uniform(<span class="hljs-number">3</span>, <span class="hljs-number">10</span>)) <span class="hljs-comment"># 3-10⼩数</span><br><br>print(random.randint(<span class="hljs-number">1</span>, <span class="hljs-number">10</span>)) <span class="hljs-comment"># 1-10整数 [1, 10]</span><br><br>print(random.randrange(<span class="hljs-number">1</span>, <span class="hljs-number">10</span>, <span class="hljs-number">2</span>)) <span class="hljs-comment"># 1-10奇数 [1,10)</span><br><br>print(random.choice([<span class="hljs-number">1</span>, <span class="hljs-string">'周杰伦'</span>, [<span class="hljs-string">"盖伦"</span>, <span class="hljs-string">"胡辣汤"</span>]])) <span class="hljs-comment"># 1或者23或者[4,5]) </span><br><br>print(random.sample([<span class="hljs-number">1</span>, <span class="hljs-string">'23'</span>, [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>]], <span class="hljs-number">2</span>)) <span class="hljs-comment"># 列表元素任意2个组合</span><br><br>lst = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>] random.shuffle(lst) <span class="hljs-comment"># 随机打乱顺序 print(lst)</span><br></code></pre></div></td></tr></table></figure>
<h4 id="五-os模块"><a href="#五-os模块" class="headerlink" title="五.os模块"></a>五.os模块</h4><p>所有操作系统相关os模式</p>
<figure class="highlight"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">os.makedirs('dirname1/dirname2') 可⽣成多层递归⽬录 <br>os.removedirs('dirname1') 若⽬录为空，则删除，并递归到上⼀级⽬录，如若也为空，则删 除，依此类推 os.mkdir('dirname') ⽣成单级⽬录；相当于shell中mkdir dirname <br>os.rmdir('dirname') 删除单级空⽬录，若⽬录不为空则⽆法删除，报错；相当于shell中 rmdir dirname os.listdir('dirname') 列出指定⽬录下的所有⽂件和⼦⽬录，包括隐藏⽂件，并以列表⽅式 打印<br>os.remove() 删除⼀个⽂件 os.rename("oldname","newname") 重命名⽂件/⽬录 <br>os.stat('path/filename') 获取⽂件/⽬录信息<br><br>os.system("bash command") 运⾏shell命令，直接显示 <br>os.popen("bash command).read() 运⾏shell命令，获取执⾏结果<br>os.getcwd() 获取当前⼯作⽬录，即当前python脚本⼯作的⽬录路径 <br>os.chdir("dirname") 改变当前脚本⼯作⽬录；相当于shell下cd<br><br># os.path os.path.abspath(path) 返回path规范化的绝对路径<br>         <br>os.path.split(path) 将path分割成⽬录和⽂件名⼆元组返回<br>os.path.dirname(path) 返回path的⽬录。其实就是 #b = os.path.dirname(os.path.dirname(__file__)) #上一级目录<br>os.path.split(path)的第⼀个元素 <br>os.path.basename(path) 返回path最后的⽂件名。如何path以／或\结尾，那么就会返回空值。 即`os.path.split(path)的第⼆个元素<br>os.path.exists(path) 如果path存在，返回True；如果path不存在，返回False <br>os.path.isabs(path) 如果path是绝对路径，返回True <br>os.path.isfile(path) 如果path是⼀个存在的⽂件，返回True。否则返回False <br>os.path.isdir(path) 如果path是⼀个存在的⽬录，则返回True。否则返回False <br>os.path.join(path1[, path2[, ...]]) 将多个路径组合后返回，第⼀个绝对路径之前的参数 将被忽略 os.path.getatime(path) 返回path所指向的⽂件或者⽬录的最后访问时间<br>os.path.getmtime(path) 返回path所指向的⽂件或者⽬录的最后修改时间 <br>os.path.getsize(path) 返回path的⼤⼩<br><br># 特殊属性: os.sep os.linesep os.pathsep os.name<br><br>输出操作系统特定的路径分隔符，win下为"\\",Linux下为"/"<br><br>输出当前平台使⽤的⾏终⽌符，win下为"\r\n",Linux下为"\n" 输出⽤于分割⽂件路径的字符串 win下为;,Linux下为: 输出字符串指示当前使⽤平台。win-&gt;'nt'; Linux,mac -&gt;'posix'<br></code></pre></div></td></tr></table></figure>
<p>Python 的 os 模块封装了常见的文件和目录操作，本文只列出部分常用的方法，更多的方法可以查看<a href="https://docs.python.org/3/library/os.path.html" target="_blank" rel="noopener">官方文档</a>。</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">方法	说明<br>os.mkdir	 创建目录<br>os.rmdir	 删除目录<br> os.rename	 重命名<br>os.remove	删除文件<br> os.getcwd	获取当前工作路径<br>os.walk	遍历目录<br>os.path.join	连接目录与文件名<br>os.path.split	分割文件名与目录<br>os.path.abspath	获取绝对路径<br>os.path.dirname	获取路径<br>os.path.basename	获取文件名或文件夹名<br>os.path.splitext	分离文件名与扩展名<br>os.path.isfile	判断给出的路径是否是一个文件<br>os.path.isdir	判断给出的路径是否是一个目录<br></code></pre></div></td></tr></table></figure>
<h5 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h5><ul>
<li><a href="http://www.cnblogs.com/rollenholt/archive/2012/04/23/2466179.html" target="_blank" rel="noopener">关于python文件操作 - Rollen Holt</a></li>
<li><a href="http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/0013868321590543ff305fb9f9949f08d760883cc243812000" target="_blank" rel="noopener">操作文件和目录 - 廖雪峰的官方网站</a></li>
<li><a href="http://blog.csdn.net/bagboy_taobao_com/article/details/893" target="_blank" rel="noopener">Python os.walk的用法与举例</a></li>
</ul>
<h5 id="os-stat-属性解读"><a href="#os-stat-属性解读" class="headerlink" title="os.stat()属性解读"></a>os.stat()属性解读</h5><figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">stat 结构:<br><br>st_mode: inode 保护模式 <br>st_ino: inode 节点号。 <br>st_dev: inode 驻留的设备。 <br>st_nlink: inode 的链接数。 <br>st_uid: 所有者的⽤户ID。 <br>st_gid: 所有者的组ID。<br>st_size: 普通⽂件以字节为单位的⼤⼩；包含等待某些特殊⽂件的数据。 <br>st_atime: 上次访问的时间。 <br>st_mtime: 最后⼀次修改的时间。 <br>st_ctime: 由操作系统报告的<span class="hljs-string">"ctime"</span>。在某些系统上（如Unix）是最新的元数据更改的时间，在 其它系统上（如Windows）是创建时间（详细信息参⻅见平台的⽂档）。<br></code></pre></div></td></tr></table></figure>
<h4 id="六-sys模块"><a href="#六-sys模块" class="headerlink" title="六.sys模块"></a>六.sys模块</h4><p>所有和python解释器sys模块</p>
<figure class="highlight python"><table><tr><td class="gutter hljs"><div class="hljs code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></div></td><td class="code"><div class="hljs code-wrapper"><pre><code class="hljs python">sys.argv 命令⾏参数List，第⼀个元素是程序本身路径<br>sys.exit(n)退出程序，正常退出时exit(<span class="hljs-number">0</span>),错误退出sys.exit(<span class="hljs-number">1</span>)<br>sys.version  获取Python解释程序的版本信息 <br><br>sys.path   返回模块的搜索路径，初始化时使⽤PYTHONPATH环境变量的值 <span class="hljs-comment">#谨慎操作</span><br>sys.platform   返回操作系统平台名称<br><br>print(sys.modules.keys())<br>print(sys.path.append)<br></code></pre></div></td></tr></table></figure>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Python/">Python</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2018/10/09/python常用模块02/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">python常用模块02</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2018/09/27/Python类与类之间的关系(3)/">
                        <span class="hidden-mobile">Python类与类之间的关系(3)</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments" lazyload>
                
                  
                
                

              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
